package cn.tedu.csmall.product.controller;

import cn.tedu.csmall.commons.pojo.vo.PageData;
import cn.tedu.csmall.commons.web.JsonResult;
import cn.tedu.csmall.product.pojo.param.AlbumInsertParam;
import cn.tedu.csmall.product.pojo.param.AlbumUpdateInfoParam;
import cn.tedu.csmall.product.pojo.param.PictureInsertParam;
import cn.tedu.csmall.product.pojo.vo.AlbumListVO;
import cn.tedu.csmall.product.pojo.vo.PictureListVO;
import cn.tedu.csmall.product.service.AlbumService;
import cn.tedu.csmall.product.service.PictureService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/picture")
@Api(tags = "11.图片管理模块")
@Slf4j
@Validated
public class PictureController {

    @Autowired
    PictureService service;

    @PostMapping("/insert")
    @ApiOperation("添加图片")
    @ApiOperationSupport(order = 100)
    public JsonResult insert(PictureInsertParam pictureInsertParam){
        service.insert(pictureInsertParam);
        return JsonResult.ok();
    }

    @PostMapping("/listByAlbumId")
    @ApiOperation("根据相册ID查询图片列表")
    @ApiOperationSupport(order = 400)
    public JsonResult listByAlbumId(Long id){
        List<PictureListVO> pictureList= service.listByAlbumId(id);
        return JsonResult.ok(pictureList);
    }
}
